<?php
/**
 * Created by PhpStorm.
 * User: xkq
 * Date: 2017/12/8 0008
 * Time: 22:16
 */
set_include_path(dirname(dirname(__FILE__)));
include_once("inc/init.php");
if (!session_id()) session_start();

$action = crequest("action");
$action = $action == '' ? 'list' : $action;

switch ($action)
{
    case "list":
        mobile_list();
        break;
}




function mobile_list()
{
    global $db, $smarty;
    //搜索条件
    $mobile 	= crequest('keyword');
    $con=" WHERE 1=1";
    if($mobile){
        $con.= " and mobile = '$mobile'";
    }

    $smarty->assign('keyword'    ,   $mobile);

    $order 	 	= 'order BY id DESC';

    //列表信息
    $now_page 	= irequest('page');
    $now_page 	= $now_page == 0 ? 1 : $now_page;
    $page_size 	= 30;
    $start    	= ($now_page - 1) * $page_size;
    $sql 		= "SELECT * FROM mobile_log {$con} {$order} LIMIT {$start},{$page_size}";
    $arr 		= $db->get_all($sql);

    $sql 		= "SELECT COUNT(id) FROM mobile_log {$con}";
    $total 		= $db->get_one($sql);
    $page     	= new page(array('total'=>$total, 'page_size'=>$page_size));

    $smarty->assign('mobile_list',$arr);
    $smarty->assign('pageshow',$page->show(6));
    $smarty->assign('now_page',$page->now_page);

    $smarty->assign('page_title', '电话记录列表');
    $smarty->display('mobile/mobile_list.htm');
}

?>

